package dao.oc_voyage_pla;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.ArrayList;
import java.util.List;
import entitybean.oc_voyage_pla.EnitityBeanOc_Voyage_Pla;

public class DaoImpl_Oc_Voyage_Pla  extends HibernateDaoSupport implements Dao_Oc_Voyage_Pla{
	public void Insert_Oc_Voyage_Pla(EnitityBeanOc_Voyage_Pla e)
	{
		this.getHibernateTemplate().save(e);
	}
	public void Update_Oc_Voyage_Pla(EnitityBeanOc_Voyage_Pla e)
	{
		this.getHibernateTemplate().update(e);
	}
	@SuppressWarnings("unchecked")
	public void Delete_Oc_Voyage_Pla(String id)
	{
		List<EnitityBeanOc_Voyage_Pla> list=this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Pla where del='OFF' and id in("+id+")");	
		for(int i=0;i<list.size();i++)
		{
			EnitityBeanOc_Voyage_Pla e=list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);
			
		}
	}
	
	@SuppressWarnings("unchecked")
	public EnitityBeanOc_Voyage_Pla Find_EnitityBeanOc_Voyage_Pla(Integer id)
	{
		EnitityBeanOc_Voyage_Pla e= new EnitityBeanOc_Voyage_Pla();
		List<EnitityBeanOc_Voyage_Pla> list=this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Pla where del='OFF' and id="+id);
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
	
	}
	@SuppressWarnings("unchecked")
	public List<EnitityBeanOc_Voyage_Pla> Find_EnitityBeanOc_Voyage_Pla() {
		List<EnitityBeanOc_Voyage_Pla> list=new ArrayList<EnitityBeanOc_Voyage_Pla>();
		list=this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Pla where del='OFF' ");
		return list;
	}
	@SuppressWarnings("unchecked")
	public List<EnitityBeanOc_Voyage_Pla> Find_Oc_Voyage_Pla_By_boatid(Integer id)
	{
		List<EnitityBeanOc_Voyage_Pla> list=new ArrayList<EnitityBeanOc_Voyage_Pla>();
		list=this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Pla where del='OFF' and boatid="+id);
		return list;
		
		
	}
}
